﻿using Biomedica.Graphics;
using KinectWindows.Controls;
using NuiDicomPlayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DicomViewerAdvanced.VirtualMouse
{
    delegate void UpdateProgrssBox();
    /// <summary>
    /// Interaction logic for mouseImposter.xaml
    /// </summary>
    public partial class mouseImposter : UserControl
    {
        private bool enable;
        public bool Enabled
        {
            set
            {
                enable = value;
                if (enable)
                {
                    this.Visibility = Visibility.Visible;
                }
                else
                {
                    this.Visibility = Visibility.Collapsed;
                }
            }
            get
            {
                return enable;
            }
        }
        public NuiControl OwnerControl { get; set; }
        Storyboard sb = new Storyboard();
        DoubleAnimation d;
        public Point Location;
        private Point OldLocation;
        private int State;
        private bool isProgressing=false;
        public mouseImposter()
        {
            InitializeComponent();
           
        }
        //private void invokeItemClicked()
        //{
        //    ResetTimer();
        //    if (OwnerControl != null && NuiControl.OnHandFiredEventRoutedEvent!=null) OwnerControl.RaiseEvent(new RoutedEventArgs(NuiControl.OnHandFiredEventRoutedEvent, this));  
           
        //}
        public void StartTimer()
        {
          
                d = new DoubleAnimation(0, this.ActualWidth, new Duration(TimeSpan.FromMilliseconds(2000)));
                d.Completed += d_Completed;
                progressbox.BeginAnimation(Rectangle.WidthProperty, d);
                isProgressing = true;
          
         
        }
        void d_Completed(object sender, EventArgs e)
        {
          //  invokeItemClicked();
            
        }
        public void ResetTimer()
        {
            progressbox.BeginAnimation(Rectangle.WidthProperty, null);
           
         
        }
        //public void UpdateHand(Biomedica.Graphics.Vector2 v, SubviewBase mainWindow)
        //{
           
        //    if (App.ActiveMouse.Enabled)
        //    {
        //        App.ActiveMouse.Location = new Point(v.X, v.Y);
        //        // Add line to test the new mouse algorithem
        //        // based om delata change
        //        int deltax = System.Math.Sign(OldLocation.X - App.ActiveMouse.Location.X);
        //        int deltay = System.Math.Sign(OldLocation.Y - App.ActiveMouse.Location.Y);

        //        /////   end

        //        App.ActiveMouse.Location.X += deltax;
        //        App.ActiveMouse.Location.Y += deltay;

        //        HitTest(mainWindow);

        //        Canvas.SetLeft(this, App.ActiveMouse.Location.X - (this.ActualWidth / 2));
        //        Canvas.SetTop(this, App.ActiveMouse.Location.Y - (this.ActualHeight / 2));

        //        OldLocation = Location;
        //    }
            

        //}
        //public virtual void HitTest(SubviewBase mainWindow)
        //{
           
        //}

    }
}
